package cn.xinfei.xdecision.manager.controller.monitor.logger;

import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.ResponseEntityBuilder;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.monitor.logger.OperateLog;
import cn.xinfei.xdecision.common.model.monitor.logger.vo.OperateLogPageReqVO;
import cn.xinfei.xdecision.common.model.monitor.logger.vo.OperateLogRespVO;
import cn.xinfei.xdecision.common.service.monitor.logger.OperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "监控中心-操作日志")
@RestController
@RequestMapping("v3/operateLog")
@ResponseBody
@Validated
public class OperateLogController {

    @Autowired
    private OperateLogService operateLogService;


    @GetMapping(value = "/page")
    @ApiOperation("查看操作日志分页列表")
    public ResponseEntityDto<PageResult<List<OperateLogRespVO>, OperateLog>> pageOperateLog(@Valid OperateLogPageReqVO operateLogPageReqVO) {

        return operateLogService.getOperateLogPage(operateLogPageReqVO);
    }

    @GetMapping(value = "getLogInfo/{id}")
    @ApiOperation("查看单条日志详情")
    public ResponseEntityDto<OperateLogRespVO> getLogInfo(@PathVariable Long id) {
        return ResponseEntityBuilder.buildNormalResponse(operateLogService.getOperateLogInfoById(id));
    }

}
